@extends('Admin.layouts.common')

@section('content')
    <div class="container myContainer">

        <button class="btn btn-info searchBtn" onclick="$('.search_box').slideToggle();">搜索/筛选</button>
        <div class="search_box">
            <form id="search_form" method="GET">
            	<label>
                    Uid：<br>
                    <input type="text" name="uid" class="form-control search_form_control" value="{{$_search['uid']??''}}">
                </label>
                <label>
                    邀请码：<br>
                    <input type="text" name="invitation_code" class="form-control search_form_control" value="{{$_search['invitation_code']??''}}">
                </label>
                <label>
                    手机号<br>
                    <input type="text" name="phone" class="form-control search_form_control" value="{{$_search['phone']??''}}">
                </label>
                
                <button class="btn btn-primary" type="submit">&nbsp;&nbsp;确定&nbsp;&nbsp;</button>
            </form>
        </div>

        <div id="order_tag"></div>

        <div class="table-responsive">
            <table class="table">
                <tr>
                    <td>总收益金额：{{$group->coin_all}}元</td>
                    <td>邀请收入（元）：{{$group->app_stage}}</td>
                    <td>直属分成收入（元）：{{$group->app_tribute}}</td>
                    <td>团队分成收入-包含旗下合伙人50%（元）：{{$group->after_divide_into_coin}}</td>
                    <td>新增补贴收入（元）：{{$group->subsidy_coin}}</td>
                </tr>
            </table>
            <table class="table">
                <caption>{{$nickname}}的收益明细</caption>
                <thead>
                    <tr>
                        <th>#</th>
                        <th>Uid</th>
                        <th>邀请码</th>
                        <th>手机号</th>

                        <th>当日总收益</th>
                        <th>基础邀请收入</th>
                        <th>基础分成收入</th>
                        <th>合伙人分成未汇率转换</th>
                        <th>汇率</th>
                        <th>合伙人团队分成（转换后）</th>
                        <th>今日补贴</th>
                        <th>合伙人下级进贡</th>
                        <th>师傅id</th>
                        <th>团队总用户</th>
                        <th>团队活跃数</th>
                        <th>团队今日新增跃数</th>
                        <th>时间</th>

                    </tr>
                </thead>
                <tbody>
                    @forelse($list->items() as $item)
                        <tr id="tr_{{$item->id}}">
                            <td>{{ $item->id }}</td>
                            <td>{{ $item->uid }}</td>
                            <td>{{ $item->user->invitation_code }}</td>
                            <td>{{ $item->user->phone }}</td>
                            <td>{{ $item->coin_all }}</td>
                            <td>{{ $item->app_stage }}</td>
                            <td>{{ $item->app_tribute }}</td>
                            <td>{{ $item->divide_into_coin}}</td>
                            <td>{{ $item->proportions}}</td>
                            <td>{{ $item->after_divide_into_coin }}</td>
                            <td>{{ $item->subsidy_coin }}</td>
                            <td>{{ $item->subgrade_coin }}</td>
                            <td>{{ $item->user->pid }}</td>
                            <td>{{ ($item->user->right-$item->user->left-1)/2 }}</td>

                            <td>{{ $item->active_count }}</td>
                            <td>{{ $item->added_count }}</td>
                            <td>{{ date('Y/m/d',strtotime($item->day)) }}</td>
                            <td>
                            
                            </td>
                        </tr>
                    @empty
                        <tr><td class="text-center" colspan="9">没有数据</td></tr>
                    @endforelse
                </tbody>
            </table>
            <div class="text-center">
                {{ $list->links() }}
            </div>
        </div>

    </div>
    <link href="{{ asset('libs/select2/select2.min.css') }}" rel="stylesheet">
<script src="{{ asset('libs/select2/select2.min.js') }}"></script>
<script src="{{ asset('libs/select2/zh-CN.js') }}"></script>
<script type="text/javascript">
$("#uid").select2({
    language: "zh-CN",
    ajax:{
        url: "/Users/ajax_select2_user",
        dataType: 'json',
        delay: 600,
        method: 'POST',
        data: function (params) {
            return {
                name: params.term,
            };
        },
        processResults: function (data, params) {
            return {
                results: data.data,
            };
        },
        cache: true
    },
    placeholder:'请输入手机号码',
    allowClear: true,
    escapeMarkup: function (markup) { return markup; },
    minimumInputLength: 11,
    templateResult: function(repo){ return repo.name; },
    templateSelection: function(repo){ 
        if(repo.id === ""){
            return repo.text
        }else{
            if(repo.selected == true){
                return repo.text
            }
            return repo.name
        }
         
    } 
});
</script>

<script type="text/javascript">
$.ajaxSetup({
    headers: {
    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    }
})

function ajax_delete_theme(id){
    if(confirm('确认删除吗?')){
        $.post("/admins/ajax_delete_admin/"+id,{},function(json){
            if(json.status==1){
                $("#tr_"+json.data).fadeOut();
            }else{
                alert(json.info);
            }
        },"json");
    } 
}

function up_status(id,status){
    if(confirm("确认执行操作吗?")){
        $.post("/user/ajax_up_status/"+id,{status:status},function(json){
            if(json.status==1){
                window.location.reload();
            }else{
                alert(json.info);
            }
        },"json");
    }
}
function ajax_up_level(id,level){
    if(confirm("确认执行操作吗?")){
        $.post("/user/ajax_up_level/"+id,{level:level},function(json){
            if(json.status==1){
                window.location.reload();
            }else{
                alert(json.info);
            }
        },"json");
    }
}
</script>
@endsection